// CSC 234 01TR WalstonW

#include "include.h"

Spike::Spike(int xPosition, int yPosition, int xResolution, int yResolution)
{   
    this->xPosition = xPosition;
    this->yPosition = yPosition;
    this->xResolution = xResolution;
    this->yResolution = yResolution;
    this->start_frame = 0;
    this->end_frame = 0;
    
    // Spike-specific variable can be tweaked here
    // so when he loads in the game, he's ready to go
    hitPoints = MAX_HP;
    current_frame = 0;
    jump_distance = 0;
    jump_rate = 1;
    jumping = false;
    falling = false;
    current_state = "float";
    this->addFrames(1,"img/spike/float/spike_float1.png", 0, P2_W, P2_H);
    this->addFrames(1,"img/spike/bite/spike_bite1.png", 0, 256, 215);
    this->addFrames(1,"img/spike/bite/spike_bite2.png", 0, 256, 215);
    this->addFrames(1,"img/spike/bite/spike_bite3.png", 0, 256, 215);
    this->addFrames(1,"img/spike/bite/spike_bite2.png", 0, 256, 215);
    this->addFrames(1,"img/spike/bite/spike_bite1.png", 0, 256, 215);
    this->addFrames(1,"img/spike/death/spike_death1.png", 0, P2_W, P2_H);
}

void Spike::animate()
{         
  if (current_state == "float")
  {
    //current_frame = 0;
    start_frame = 0;
    end_frame = 0;
  }  
  if (current_state == "dying")
  {
    //current_frame = 4;
    start_frame = 6;
    end_frame = 6;
  }
  if (current_state == "biting")
  {
    start_frame = 1;
    end_frame = 5;
    /*if (current_frame == 0 || current_frame == 3){
      current_frame = 1;
    }
    else if (current_frame < 3)
      current_frame++;*/
  }    
}
